package consul

import (
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

var blackSvrID = make(map[string]struct{})

func HealthCheck(c *gin.Context) {
	id := c.Query("id")
	if _, ok := blackSvrID[id]; ok {
		c.JSON(http.StatusNotFound, "")
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"message": "success",
	})
}

func AddBlackSvrID(c *gin.Context) {
	id := c.Query("id")
	log.Printf("consul 添加黑名单：%v\n", id)
	blackSvrID[id] = struct{}{}
	c.JSON(http.StatusOK, gin.H{
		"message": "success",
		"id":      id,
	})
}
